package com.example.grape_effect.animation

import com.example.grape_effect.interpolator.UniformAccelerationInterpolator

// 学习矩阵所用，
class Left2Right : TranslateAnimation(leftToRight) {

//    override fun updateAnimationParameters() {
//
//        val projectMatrix = Matrix2DUtils.getIdentityMatrix()
//        val viewMatrix = Matrix2DUtils.getIdentityMatrix()
//        val modelMatrix = Matrix2DUtils.getIdentityMatrix()
//
////        /******************* mvp demo************************/
////        val newMatrix =  Matrix2DUtils.getIdentityMatrix()
////        val mvp = Matrix2DUtils.getIdentityMatrix()
////        Matrix.translateM(modelMatrix,0, 1f,0f, 0f)
////        Matrix.rotateM(modelMatrix,0,90f, 0f, 0f, 1f)
////        Matrix.scaleM(modelMatrix,0, 0.5f, 0.5f, 0f)
////        //正交投影, gl 默认就是正交投影，因此可以不用设置
//////        Matrix.orthoM(projectMatrix,0,-1f, 1f, -height.toFloat()/width, height.toFloat()/width, 3f,100f)
////        Matrix.orthoM(projectMatrix,0,-1f, 1f, -1f, 1f, 3f,100f)
////        Matrix.setLookAtM(viewMatrix,0, 0f,0f,100f,0f,0f,0f, 0f,1f,0f)
////        Matrix.multiplyMM(newMatrix, 0, projectMatrix, 0, viewMatrix, 0)
////        Matrix.multiplyMM(mvp, 0, modelMatrix, 0, newMatrix, 0)
////        setMatrix(mvp)
////        /******************* mvp demo end************************/
//
////        /******************* mvp demo2 与demo1效果一样************************/
////        val newMatrix = Matrix2DUtils.getIdentityMatrix()
////        val mvp = Matrix2DUtils.getIdentityMatrix()
////        var transMatrix = Matrix2DUtils.getIdentityMatrix()
////        var rotateMatrix = Matrix2DUtils.getIdentityMatrix()
////        var scaleMatrix = Matrix2DUtils.getIdentityMatrix()
////        Matrix.translateM(transMatrix, 0, 1f, 0f, 0f)
////        Matrix.rotateM(rotateMatrix, 0, 90f, 0f, 0f, 1f)
////        Matrix.scaleM(scaleMatrix, 0, 0.5f, 0.5f, 0f)
////        Matrix.multiplyMM(modelMatrix, 0, transMatrix, 0, rotateMatrix, 0)
////        Matrix.multiplyMM(modelMatrix, 0, modelMatrix, 0, scaleMatrix, 0)
////        //正交投影, gl 默认就是正交投影，因此可以不用设置
//////        Matrix.orthoM(projectMatrix,0,-1f, 1f, -height.toFloat()/width, height.toFloat()/width, 3f,100f)
////        Matrix.orthoM(projectMatrix, 0, -1f, 1f, -1f, 1f, 3f, 100f)
////        Matrix.setLookAtM(viewMatrix, 0, 0f, 0f, 100f, 0f, 0f, 0f, 0f, 1f, 0f)
////        Matrix.multiplyMM(newMatrix, 0, projectMatrix, 0, viewMatrix, 0)
////        Matrix.multiplyMM(mvp, 0, modelMatrix, 0, newMatrix, 0)
////        setMatrix(mvp)
////        /******************* mvp demo2 end************************/
//
//        // left to right
//        val mvpMatrix = Matrix2DUtils.getIdentityMatrix()
//        if (mode == ANIMATION_MODE_BY_SET_TIME_SELF) {
//            updateCurPosition(System.currentTimeMillis() - startTime)
//        }
//        Matrix.translateM(mvpMatrix, 0, curPosition[0],  curPosition[1],  curPosition[2])
//        setMatrix(mvpMatrix)
//    }

    init {
        startPosition = floatArrayOf(0f, 0f,0f)
        endPosition = floatArrayOf(2f, 0f, 0f)
        mode = ANIMATION_MODE_BY_SET_TIME_SELF
        isRepeatable = true
        positionUpdaterX = UniformAccelerationInterpolator(duration, startPosition[0], endPosition[0], 0.003f)
//        positionUpdaterX = ConstantSpeedUpdater.getAnimationUpdater(duration, startPosition[0], endPosition[0])
    }


}